﻿using System;
using Bookvar.ObjectModel;
using Bookvar.ObjectModel.Collections;

namespace Bookvar.ServiceModel
{
    /// <summary>
    /// A service that provides useful information about the current mind map.
    /// TODO: add ability to change the current <see cref="MindMap"/>.
    /// TODO: add getter for all the loaded mind maps.
    /// </summary>
    public interface IMindmapService
    {
        /// <summary>
        /// Gets the current active mindmap. Returns <a>null</a> if there is no open mind map.
        /// </summary>
        /// <value>The current active mindmap.</value>
        MindMap CurrentMindmap { get; }

        /// <summary>
        /// Gets all the loaded mind maps.
        /// </summary>
        /// <value>The loaded mind maps.</value>
        MindmapCollection LoadedMindMaps { get; }

        /// <summary>
        /// Gets or sets the currently selected topic. Returns <a>null</a> if no topic is selected.
        /// </summary>
        /// <exception cref="ArgumentNullException">if <a>value</a> is null.</exception>
        /// <exception cref="ArgumentException">if the provided topic is not in the current <see cref="MindMap"/></exception>
        /// <value>The selected topic.</value>
        Topic SelectedTopic { get; set; }

        /// <summary>
        /// Adds the <see cref="MindMap"/> to the opened mind maps. 
        /// The <see cref="MindMap"/> is automatically focused.
        /// </summary>
        /// <exception cref="ArgumentNullException">if the <paramref name="mindmap"/> is null.</exception>
        /// <param name="mindmap">The mind map.</param>
        void AddMindmap( MindMap mindmap );

        /// <summary>
        /// Adds the <see cref="MindMap"/> to the opened mindmaps. 
        /// The <see cref="MindMap"/> will be focused if the focus parameter is <a>true</a>.
        /// </summary>
        /// <exception cref="ArgumentNullException">if the <paramref name="mindmap"/> is null.</exception>
        /// <param name="mindmap">The mindmap.</param>
        /// <param name="switchToMindmap">Indicates if the <see cref="MindMap"/> should be automatically 
        /// focused after it is added.</param>
        void AddMindmap( MindMap mindmap, bool switchToMindmap );

        /// <summary>
        /// Switches to the the specified <see cref="MindMap"/>.
        /// </summary>
        /// <exception cref="ArgumentNullException">if the <paramref name="mindmap"/> is null.</exception>
        /// <param name="mindmap">The mind map that will be focused after the switch.</param>
        void SwitchToMindmap( MindMap mindmap );

        /// <summary>
        /// Opens a mind map from the specified path on the disk. After the map is loaded the focus automatically is
        /// switched to it. 
        /// <BR/>
        /// If the mind map is already open it will not be loaded again. But it will be focused.
        /// </summary>
        /// <exception cref="ArgumentException">
        /// if <paramref name="filePath"/> is null or null.
        /// </exception>
        /// <param name="filePath">The file path.</param>
        /// <returns>The opened MindMap. It does not matter if the map was already opened - it is still returned.</returns>
        MindMap OpenMindmapFromDisk( string filePath );

        /// <summary>
        /// Opens a mind map from the specified path on the disk. If the <paramref name="switchToMapAutomatically"/>
        /// is true, the focus will be switched to the newly opened <see cref="MindMap"/>.
        /// <BR/>
        /// If the mind map is already open it will not be loaded again.
        /// </summary>
        /// <exception cref="ArgumentException">
        /// if <paramref name="filePath"/> is null or null.
        /// </exception>
        /// <param name="filePath">The file path.</param>
        /// <param name="switchToMapAutomatically">Indicates if the map should be focused after it is loaded.</param>
        /// <returns>The opened MindMap. It does not matter if the map was already opened - it is still returned.</returns>
        MindMap OpenMindmapFromDisk( string filePath, bool switchToMapAutomatically );
    }
}